package com.parkingspace.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.parkingspace.dao.ParkingInformationMapper;
import com.parkingspace.entity.ParkingInformation;
import com.parkingspace.entity.Property;
import com.parkingspace.service.IParkingInformationService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 车位信息表 服务实现类
 * </p>
 *
 * @author Gapper
 * @since 2021-05-24
 */
@Service
public class ParkingInformationServiceImpl extends ServiceImpl<ParkingInformationMapper, ParkingInformation> implements IParkingInformationService {

    @Resource
    private  ParkingInformationMapper parkingInformationMapper;

    @Override
    public List<ParkingInformation> getParkingByUid(Long id) {
        System.out.println("ParkingInformationimpl进来了"+id);
        ArrayList<Integer> list = new ArrayList<>();
        list.add(3);
        list.add(4);
        QueryWrapper<ParkingInformation> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("parking_uid",id).in("parking_status",list);

        List<ParkingInformation> parkingInformationList = parkingInformationMapper.selectList(queryWrapper);

        return parkingInformationList;
    }

    @Override
    public  List<ParkingInformation> getParkingByPid(Long pbuPropertyId) {
        System.out.println("ParkingInformationServiceImpl的getParkingByPid（）进来了："+pbuPropertyId);
        QueryWrapper<ParkingInformation> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("property_id",pbuPropertyId);
        List<ParkingInformation> parkingInformations = parkingInformationMapper.selectList(queryWrapper);

        return parkingInformations;
    }

    @Override
    public boolean updateShareById(ParkingInformation information) {
        ParkingInformation p = new ParkingInformation();
        p.setParkingId(information.getParkingId());
        p.setParkingProportion(information.getParkingProportion());
        return  parkingInformationMapper.updateById(p)==1?true:false;

    }


}
